/**
 * 实现生成查验记录页面
 *
 * @param operate_status 判断当前操作是写还是编辑或者是读操作 值分别为write,edit,read
 * @method  _init:业务编号，收发货人数据渲染；生成拼单业务编号那个表格；生成默认查验记录表格；查验柜号下拉选框数据渲染
 * @method  _initDatePicker:查验时间初始化
 * @method  _dictionaryQuery:从数据字典中加载数据
 * @method  _checkDeptsBind:查验单位选择如果选择了其他将会出现一个input框
 * @method  _generateCheckRecordTable:用来生成查验记录表格的方法
 * @method  _generateCabinetLinkTable:当勾选了柜号生成拼单业务编号+收发货人表格的方法
 * @method  _load：主要实现柜号的勾选触发事件从而引起拼单业务编号+收发货人表格的生成
 * @method  _defaultMultiSelectAllBind：查验柜号中下拉多选框中勾选了all后触发的事件
 * @method  _defaultMultiSelectBind：查验柜号中下拉多选框中勾选后触发的事件
 * @method  _cabinetLinkTableInputBind：拼单业务编号+收发货人表格中多选框触发的事件
 * @method  _getMultiInputId：获取查验柜号中下拉多选框中的id值
 * @method  _getFormParams：获取表单中的提交值
 */
var __PROTOTYPE__ = {
    _init: function () {
        var layerIndex;
        var _this = this;
        this.$checkRecoreSectionDefault = $(".checkRecore-section-default");
        $.ajax({
                   /*url:'../assets/js/testData/record.js',*/
                   url: '/api/verify/getAboutInfo',
                   type: 'get',
                   data: _this._getUrlSearch(),
                   /*data: {"bussId": "BE201705090078"},*/
                   /*data: {"bussId": "BE201706050192"},*/
                   dataType: 'json',
                   beforeSend: function () {
                       layerIndex = layer.load(1, {
                           shade: [0.5, '#000']
                       });
                   },
                   success: function (data) {
                       console.log(data);
                       layer.close(layerIndex);
                       var multiInitData = [];
                       var multiAttrIndex = [];
                       _this.result = data.content;
                       if (data.error_code == 0) {
                           _this._generateCheckRecordTable(_this.$checkRecoreSectionDefault,
                                                           "查验记录1", _this.result);
                           for (var i = 0; i < _this.result.length; i++) {
                               $(".content-section").find(".check-bussinessNo").text(_this.result[i].bussNo).end().find(".check-owner").text(_this.result[i].ioer);
                               /*var $clone=$(".checkRecord-table-template").clone().removeClass("checkRecord-table-template");
                                $clone.find(".check-sequence").text("查验记录1").end().find(".check-declaraNo").text(result[i].declaNo).end().find(".check-businessNo").text(result[i].bussNo).end().find(".check-reallyOwner").text(result[i].trueUser).end().find(".check-owner").text(result[i].ioer);
                                生成查验商品
                                for(var k=0;k<result[i].goodsList.length;k++){
                                var optionHtml="<option value='"+result[i].goodsList[k].goodsId+"'>"+result[i].goodsList[k].goodsName+"</option>";
                                $clone.find(".check-goods-select").append(optionHtml);
                                }*/
                               /*生成拼单业务编号那个表格*/
                               for (var j = 0; j < _this.result[i].contaList.length; j++) {
                                   var labelName = ((j == 0) ? "柜号：" : "");
                                   var val = _this.result[i].contaList[j].contaNo;
                                   var cabinetNameHtml = "<tr>" +
                                                         "<td class=\"cabinet-label\">" + labelName
                                                         +
                                                         "</td>" +
                                                         "<td class=\"cabinet-content\">" +
                                                         "<input type=\"checkbox\" value='" + val
                                                         + "'" + " " + "attrIndex='" + j + "'/>"
                                                         + val +
                                                         "</td>" +
                                                         "</tr>";
                                   _this.$cabinetNameTable = $(".cabinet-name");
                                   _this.$cabinetNameTable.find("tbody").append(cabinetNameHtml);
                                   multiInitData.push(_this.result[i].contaList[j].contaNo);
                                   multiAttrIndex.push(j);

                               }
                           }
                           _this.$checkRecoreDefaultTable =
                           _this.$checkRecoreSectionDefault.find("table:not(.checkRecord-table-template)");
                           _this.$checkRecoreMultiSelect =
                           _this.$checkRecoreDefaultTable.find('.multi_select');
                           _this.$checkRecoreMultiSelect.MSDL({
                                                                  'width': '200',
                                                                  'data': multiInitData,
                                                                  'index': multiAttrIndex,
                                                                  'type': "checkbox"
                                                              });
                           _this._load();
                           if (_this.result.length == 1 && _this.result[0].contaList.length == 1) {
                               $(".cabinet-name").find("input[type=checkbox]").click();
                           }
                           /*_this._dictionaryQuery("checkDepts",_this.$checkRecoreDefaultTable,".check-depts-select");
                            _this._dictionaryQuery("checkItems",_this.$checkRecoreDefaultTable,".check-items-select");*/
                           _this._defaultMultiSelectBind();
                           _this._defaultMultiSelectAllBind();
                       } else {
                           alert("内部系统出错了");
                       }
                   },
                   error: function (a, b, c) {
                       console.log(b);
                   }
               });
    },
    _getUrlSearch: function () {
        var search = window.location.search.substr(1);
        return search;
    },
    _initDatePicker: function (table) {
        table.find(".datepicker").datepicker();
    },
    _dictionaryQuery: function (table, select, dictionaryName) {
        var _this = this;
        $.ajax({
                   /*url: '../assets/js/testData/' + url + '.js',*/
                   url: '/api/dictionary/search',
                   type: 'get',
                   dataType: 'json',
                   data: {dtGroupCode: dictionaryName},
                   success: function (data) {
                       console.log(data);
                       var result = data.content;
                       var multiInitData = [];
                       var multiAttrIndex = [];
                       if (data.error_code == 0) {
                           for (var i = 0; i < result.length; i++) {
                               if(result[i].dtValue!=undefined&&result[i].dtId!=undefined){
                                   multiInitData.push(result[i].dtValue);
                                   multiAttrIndex.push(result[i].dtId);
                               }

                               /*var optionHtml="<option value="+result[i].dtId+">"+result[i].dtValue+"</option>";
                                table.find(select).append(optionHtml);*/
                           }
                           table.find(select).MSDL({
                                                       'width': '200',
                                                       'data': multiInitData,
                                                       'index': multiAttrIndex,
                                                       'type': dictionaryName == 'verify_dept'
                                                           ? "radio" : 'checkbox'
                                                   });
                           _this._checkDeptsBind();
                           _this._checkItemsBind();
                       } else {
                           alert("系统内部错误");
                       }
                   },
                   error: function (a, b, c) {
                       console.log(b);
                   }
               });
    },
    _checkDeptsBind: function () {
        $(".check-depts-select .content input").on("click", function () {
            if ($(this).get(0).checked) {
                if ($(this).val() == "其他") {
                    $(this).parents(".check-depts-select").next(".checkDepts-input-container").show();
                } else {
                    $(this).parents(".content").find("div").each(function (i, n) {
                        if ($(this).find("input").get(0).checked && $(this).find("input").val()
                                                                    == "其他") {
                            $(this).parents(".check-depts-select").next(".checkDepts-input-container").show();
                            return false;
                        } else {
                            $(this).parents(".check-depts-select").next(".checkDepts-input-container").hide();
                        }
                    });
                }
            } else {
                $(this).parents(".content").find("div").each(function (i, n) {
                    if ($(this).find("input").get(0).checked && $(this).find("input").val()
                                                                == "其他") {
                        $(this).parents(".check-depts-select").next(".checkDepts-input-container").show();
                        return false;
                    } else {
                        $(this).parents(".check-depts-select").next(".checkDepts-input-container").hide();
                    }
                });
            }
        });
    },
    _checkItemsBind: function () {
        $(".check-items-select .content input").on("click", function () {
            if ($(this).get(0).checked) {
                if ($(this).val() == "其他") {
                    $(this).parents(".check-items-select").next(".checkItems-input-container").show();
                } else {
                    $(this).parents(".content").find("div").each(function (i, n) {
                        if ($(this).find("input").get(0).checked && $(this).find("input").val()
                                                                    == "其他") {
                            $(this).parents(".check-items-select").next(".checkItems-input-container").show();
                            return false;
                        } else {
                            $(this).parents(".check-items-select").next(".checkItems-input-container").hide();
                        }
                    });
                }
            } else {
                $(this).parents(".content").find("div").each(function (i, n) {
                    if ($(this).find("input").get(0).checked && $(this).find("input").val()
                                                                == "其他") {
                        $(this).parents(".check-items-select").next(".checkItems-input-container").show();
                        return false;
                    } else {
                        $(this).parents(".check-items-select").next(".checkItems-input-container").hide();
                    }
                });
            }
        });
    },
    _generateCheckRecordTable: function (checkRecoreSection, checkSequenceText, data) {
        var multiInitData = [];
        var multiAttrIndex = [];
        for (var i = 0; i < data.length; i++) {
            var $clone = $(".checkRecord-table-template").clone().removeClass("checkRecord-table-template");
            $clone.find(".check-declaraNo").text(data[i].declaNo?data[i].declaNo:'').end().find(".check-businessNo").text(data[i].bussNo).end().find(".check-reallyOwner").text(data[i].trueUser).end().find(".check-owner").text(data[i].ioer).end().find(".check-sequence .check-sequence-span").text(checkSequenceText).next("input").val(data[i].bussId);
            /*$clone.find(".check-sequence").text(checkSequenceText).end().find(".check-declaraNo").text(data[i].declaNo).end().find(".check-businessNo").text(data[i].bussNo).end().find(".check-reallyOwner").text(data[i].trueUser).end().find(".check-owner").text(data[i].ioer);*/
            /*生成查验商品*/
            for (var k = 0; k < data[i].goodsList.length; k++) {
                multiInitData.push(data[i].goodsList[k].goodsName);
                multiAttrIndex.push(data[i].goodsList[k].goodsId);
                /*var optionHtml="<option value='"+data[i].goodsList[k].goodsId+"'>"+data[i].goodsList[k].goodsName+"</option>";
                 $clone.find(".check-goods-select").append(optionHtml);*/
            }
        }
        $clone.find(".check-goods-select").MSDL({
                                                    'width': '200',
                                                    'data': multiInitData,
                                                    'index': multiAttrIndex,
                                                    'type': 'checkbox'
                                                });
        /*this.$checkRecoreSectionDefault.append($clone);*/
        checkRecoreSection.append($clone);
        this._initDatePicker($clone);
        /*this._dictionaryQuery("checkDepts", $clone, ".check-depts-select", 'CHECK_DEPTS');
         this._dictionaryQuery("checkItems", $clone, ".check-items-select", 'CHECK_ITEMS');*/
        this._dictionaryQuery($clone, ".check-depts-select", 'verify_dept');
        this._dictionaryQuery($clone, ".check-items-select", 'verify_case');
    },
    _generateCabinetLinkTable: function (selectArr, queryResult) {
        /*console.log(this.linkSelectInputArr);*/
        if (selectArr.length) {
            var maxLen = selectArr[0].len;
            if (selectArr.length > 1) {
                for (var i = 1; i < selectArr.length; i++) {
                    if (selectArr[i].len > maxLen) {
                        maxLen = selectArr[i].len;
                    }
                }
            }
            for (var i = 0; i < maxLen; i++) {
                this.$cabinetLinkTable.find("thead tr").append("<td></td>");
            }
            var remainIndexArr = [];
            for (var i = 0; i < selectArr.length; i++) {
                remainIndexArr.push(parseInt(selectArr[i].indexOf));
            }
            for (var j = 0; j < this.$cabinetNameInput.length; j++) {
                var $trHtml = $("<tr></tr>");
                for (var i = 0; i < maxLen; i++) {
                    if (($.inArray(j, remainIndexArr) != -1)) {
                        var val = queryResult[0].contaList[j].bindDeclaList[i]
                            ? queryResult[0].contaList[j].bindDeclaList[i] : "";
                        /*console.log(this.linkSelectInputArr);*/
                        var isChecked = ($.inArray(val.bussId, this.linkSelectInputArr) != -1)
                            ? "checked" : "";
                        /*var isChecked=(val?(val.bussId?($.inArray(val.bussId,this.linkSelectInputArr))):"");*/
                        /*var addInputHtml=val?"<input type='checkbox' value='"+(val?val.bussId:"")+"'/>":"";*/
                        /*addInputHtml?$(addInputHtml).get(0).checked=isChecked:"";*/
                        var addInputHtml = val ? "<input type='checkbox' value='" + (val
                            ? val.bussId : "") + "'" + " " + isChecked + "/>" : "";
                        $trHtml.append("<td>" + addInputHtml + (val ? val.bussNo : "") + (val ? "+"
                                                                                                + val.ioer
                            : "") + "</td>");
                    } else {
                        $trHtml.append("<td></td>");
                    }

                }
                this.$cabinetLinkTable.find("tbody").append($trHtml);
            }
        }
    },
    _load: function () {
        var _this = this;
        this.cabinetNoArr = [];
        this.cabinetNameInputArr = [];
        this.linkSelectInputArr = [];
        this.$cabinetNameInput = $(".cabinet-name").find("input[type=checkbox]");
        this.len = _this.$cabinetNameInput.length;
        this.$cabinetLinkTable = $(".cabinet-link");
        this.$cabinetNameInput.on("click", function (event) {
            var obj = {};
            var count = 0;
            _this.$cabinetLinkTable.find("thead td").remove().end().find("tbody tr").remove();
            if ($(this).get(0).checked) {
                var indexOf = $(this).attr("attrindex");
                var val = $(this).val();
                obj.indexOf = indexOf;
                obj.val = val;
                obj.len = _this.result[0].contaList[indexOf].bindDeclaList.length;
                _this.cabinetNameInputArr.push(obj);
                _this.cabinetNoArr.push($(this).val());
                _this.$checkRecoreDefaultTable.find(".multi_select_cabinetNo .select_rel").val(_this.cabinetNoArr.join(";"));
                _this._generateCabinetLinkTable(_this.cabinetNameInputArr, _this.result);
            } else {
                var index;
                var cabinetNoIndex = _this.cabinetNoArr.indexOf($(this).val());
                _this.cabinetNoArr.splice(cabinetNoIndex, 1);
                var indexOf = $(this).attr("attrindex");
                for (var i = 0; i < _this.cabinetNameInputArr.length; i++) {
                    if (_this.cabinetNameInputArr[i].indexOf == indexOf) {
                        index = i;
                        break;
                    }
                }
                _this.cabinetNameInputArr.splice(index, 1);
                for (var i = 0; i < _this.result[0].contaList[indexOf].bindDeclaList.length; i++) {
                    if ($.inArray(_this.result[0].contaList[indexOf].bindDeclaList[i].bussId,
                                  _this.linkSelectInputArr) != -1) {
                        var index2 = _this.linkSelectInputArr.indexOf(_this.result[0].contaList[indexOf].bindDeclaList[i].bussId);
                        _this.linkSelectInputArr.splice(index2, 1);
                        $("div[attrBussId="
                          + _this.result[0].contaList[indexOf].bindDeclaList[i].bussId
                          + "]").remove();
                        $(".contact-wrap").each(function (i, n) {
                            $(this).find("table thead td:first-child").text(" ").text("查验记录" + (i
                                                                                                + 2));
                        });
                    }
                }
                var index3;
                var selectRelArr = _this.$checkRecoreDefaultTable.find(".multi_select_cabinetNo .select_rel").val().split(";");
                for (var i = 0; i < selectRelArr.length; i++) {
                    if (selectRelArr[i] == $(this).val()) {
                        index3 = i;
                        break;
                    }
                }
                console.log(index3);
                selectRelArr.splice(index3, 1).join(";");
                _this.$checkRecoreDefaultTable.find(".multi_select_cabinetNo .select_rel").val(selectRelArr);
                _this._generateCabinetLinkTable(_this.cabinetNameInputArr, _this.result);
            }
            _this.$checkRecoreSelectAll = _this.$checkRecoreMultiSelect.find(".select_all");
            _this.$checkRecoreMultiSelect.find(".content").find("input[type=checkbox]").each(function () {
                if ($.inArray($(this).val(), _this.cabinetNoArr) != -1) {
                    count++;
                    $(this).get(0).checked = true;
                    if (count == _this.len) {
                        _this.$checkRecoreSelectAll.get(0).checked = true;
                    } else {
                        _this.$checkRecoreSelectAll.get(0).checked = false;
                    }
                } else {
                    $(this).get(0).checked = false;
                }
            });
            _this._cabinetLinkTableInputBind();
        });
    },
    _defaultMultiSelectAllBind: function () {
        var _this = this;
        this.$checkRecoreMultiSelect.find(".select_all").on("click", function () {
            if ($(this).get(0).checked) {
                _this.cabinetNoArr = [];
                _this.cabinetNameInputArr = [];
                $(this).parents(".container").find(".content input").each(function () {
                    $(this).get(0).checked = true;
                });
                _this.$cabinetNameInput.each(function () {
                    var obj = {};
                    $(this).get(0).checked = true;
                    _this.$cabinetLinkTable.find("thead td").remove().end().find("tbody tr").remove();
                    var indexOf = $(this).attr("attrindex");
                    var val = $(this).val();
                    obj.indexOf = indexOf;
                    obj.val = val;
                    obj.len = _this.result[0].contaList[indexOf].bindDeclaList.length;
                    _this.cabinetNameInputArr.push(obj);
                    _this.cabinetNoArr.push($(this).val());
                    _this._generateCabinetLinkTable(_this.cabinetNameInputArr, _this.result);
                });
            } else {
                _this.cabinetNoArr = [];
                _this.cabinetNameInputArr = [];
                _this.linkSelectInputArr = [];
                _this.$cabinetLinkTable.find("thead td").remove().end().find("tbody tr").remove();
                _this.$cabinetNameInput.each(function () {
                    $(this).get(0).checked = false;
                });
                _this.$checkRecoreSectionContact.find("div").remove();
            }
            _this._cabinetLinkTableInputBind();
        });
    },
    _defaultMultiSelectBind: function () {
        var _this = this;
        _this.$checkRecoreMultiSelect.find(".content").find("input[type=checkbox]").on("click",
                                                                                       function () {
                                                                                           console.log(_this.cabinetNoArr);
                                                                                           var __this = this;
                                                                                           var indexOf = $(this).attr("attrindex");
                                                                                           if ($(this).get(0).checked) {
                                                                                               _this.cabinetNoArr.push($(this).val());
                                                                                           } else {
                                                                                               var index = _this.cabinetNoArr.indexOf($(this).val());
                                                                                               _this.cabinetNoArr.splice(index,
                                                                                                                         1);
                                                                                           }
                                                                                           if (_this.cabinetNameInputArr.length
                                                                                               == 0) {
                                                                                               _this.$cabinetNameInput.each(function () {
                                                                                                   if ($.inArray($(this).val(),
                                                                                                                 _this.cabinetNoArr)
                                                                                                       != -1) {
                                                                                                       $(this).get(0).checked =
                                                                                                       true;
                                                                                                       _this.$cabinetLinkTable.find("thead td").remove().end().find("tbody tr").remove();
                                                                                                       var obj = {};
                                                                                                       var indexOf = $(this).attr("attrindex");
                                                                                                       var val = $(this).val();
                                                                                                       obj.indexOf =
                                                                                                       indexOf;
                                                                                                       obj.val =
                                                                                                       val;
                                                                                                       obj.len =
                                                                                                       _this.result[0].contaList[indexOf].bindDeclaList.length;
                                                                                                       _this.cabinetNameInputArr.push(obj);
                                                                                                       _this._generateCabinetLinkTable(_this.cabinetNameInputArr,
                                                                                                                                       _this.result);
                                                                                                   } else {
                                                                                                       return true;
                                                                                                   }
                                                                                               });
                                                                                               console.log(_this.cabinetNameInputArr.length);
                                                                                           } else {
                                                                                               if ($(this).get(0).checked) {
                                                                                                   _this.cabinetNameInputArr =
                                                                                                   [];
                                                                                                   _this.$cabinetNameInput.each(function () {
                                                                                                       if ($.inArray($(this).val(),
                                                                                                                     _this.cabinetNoArr)
                                                                                                           != -1) {
                                                                                                           $(this).get(0).checked =
                                                                                                           true;
                                                                                                           _this.$cabinetLinkTable.find("thead td").remove().end().find("tbody tr").remove();
                                                                                                           var obj = {};
                                                                                                           var indexOf = $(this).attr("attrindex");
                                                                                                           var val = $(this).val();
                                                                                                           obj.indexOf =
                                                                                                           indexOf;
                                                                                                           obj.val =
                                                                                                           val;
                                                                                                           obj.len =
                                                                                                           _this.result[0].contaList[indexOf].bindDeclaList.length;
                                                                                                           _this.cabinetNameInputArr.push(obj);
                                                                                                           _this._generateCabinetLinkTable(_this.cabinetNameInputArr,
                                                                                                                                           _this.result);
                                                                                                       } else {
                                                                                                           return true;
                                                                                                       }
                                                                                                   });
                                                                                                   console.log(_this.cabinetNameInputArr.length);
                                                                                               } else {
                                                                                                   var index1;
                                                                                                   for (var i = 0;
                                                                                                        i
                                                                                                        < _this.cabinetNameInputArr.length;
                                                                                                        i++) {
                                                                                                       if (_this.cabinetNameInputArr[i].indexOf
                                                                                                           == indexOf) {
                                                                                                           index1 =
                                                                                                           i;
                                                                                                           break;
                                                                                                       }
                                                                                                   }
                                                                                                   _this.cabinetNameInputArr.splice(index1,
                                                                                                                                    1);
                                                                                                   for (var i = 0;
                                                                                                        i
                                                                                                        < _this.result[0].contaList[indexOf].bindDeclaList.length;
                                                                                                        i++) {
                                                                                                       if ($.inArray(_this.result[0].contaList[indexOf].bindDeclaList[i].bussId,
                                                                                                                     _this.linkSelectInputArr)
                                                                                                           != -1) {
                                                                                                           var index2 = _this.linkSelectInputArr.indexOf(_this.result[0].contaList[indexOf].bindDeclaList[i].bussId);
                                                                                                           _this.linkSelectInputArr.splice(index2,
                                                                                                                                           1);
                                                                                                           $("div[attrBussId="
                                                                                                             + _this.result[0].contaList[indexOf].bindDeclaList[i].bussId
                                                                                                             + "]").remove();
                                                                                                           $(".contact-wrap").each(function (i,
                                                                                                                                             n) {
                                                                                                               $(this).find("table thead td:first-child").text(" ").text("查验记录"
                                                                                                                                                                         + (i
                                                                                                                                                                            + 2));
                                                                                                           });
                                                                                                       }
                                                                                                   }
                                                                                                   _this.$cabinetNameInput.each(function () {
                                                                                                       $(this).get(0).checked =
                                                                                                       false;
                                                                                                       if (_this.cabinetNoArr.length
                                                                                                           == 0) {
                                                                                                           _this.$cabinetLinkTable.find("thead td").remove().end().find("tbody tr").remove();
                                                                                                       }
                                                                                                       if ($.inArray($(this).val(),
                                                                                                                     _this.cabinetNoArr)
                                                                                                           != -1) {
                                                                                                           $(this).get(0).checked =
                                                                                                           true;
                                                                                                           _this.$cabinetLinkTable.find("thead td").remove().end().find("tbody tr").remove();
                                                                                                           _this._generateCabinetLinkTable(_this.cabinetNameInputArr,
                                                                                                                                           _this.result);
                                                                                                       } else {
                                                                                                           return true;
                                                                                                       }
                                                                                                   });
                                                                                               }
                                                                                           }
                                                                                           _this._cabinetLinkTableInputBind();
                                                                                       });
    },
    _cabinetLinkTableInputBind: function () {
        var _this = this;
        /*var clickCount=1;*/
        this.$checkRecoreSectionContact = $(".checkRecore-section-contact");
        this.$cabinetLinkTable.find("input[type=checkbox]").on("click", function () {
            var contaListIndex;
            var bindDeclaListIndex;
            var bussId = $(this).val();
            var dataSource = [];
            var multiInitData = [];
            var multiAttrIndex = [];
            if ($(this).get(0).checked) {
                /*clickCount++;*/
                outFor:for (var i = 0; i < _this.result.length; i++) {
                    for (var j = 0; j < _this.result[i].contaList.length; j++) {
                        for (var k = 0; k < _this.result[i].contaList[j].bindDeclaList.length;
                             k++) {
                            if (_this.result[i].contaList[j].bindDeclaList[k].bussId == bussId) {
                                bindDeclaListIndex = k;
                                contaListIndex = j;
                                break outFor;
                            }
                        }
                    }
                }
                _this.linkSelectInputArr.push(bussId);
                dataSource.push(_this.result[0].contaList[contaListIndex].bindDeclaList[bindDeclaListIndex]);
                _this.$checkRecoreSectionContact.append("<div class='contact-wrap' attrBussId='"
                                                        + bussId + "'></div>");
                _this.$checkRecoreSectionContactWrap = $("div[attrBussId=" + bussId + "]");
                /*_this._generateCheckRecordTable(_this.$checkRecoreSectionContactWrap,"查验记录"+clickCount,dataSource);*/
                _this._generateCheckRecordTable(_this.$checkRecoreSectionContactWrap,
                                                "查验记录" + (_this.linkSelectInputArr.length + 1),
                                                dataSource);
                for (var i = 0; i < dataSource[0].contaList.length; i++) {
                    multiInitData.push(dataSource[0].contaList[i]);
                    multiAttrIndex.push(i);
                }
                _this.$checkRecoreSectionContactWrap.find(".multi_select").MSDL({
                                                                                    'width': '200',
                                                                                    'data': multiInitData,
                                                                                    'index': multiAttrIndex,
                                                                                    'type': 'checkbox'
                                                                                });
            } else {
                var index = _this.linkSelectInputArr.indexOf(bussId);
                _this.linkSelectInputArr.splice(index, 1);
                $("div[attrBussId=" + bussId + "]").remove();
                $(".contact-wrap").each(function (i, n) {
                    $(this).find("table thead td:first-child").text(" ").text("查验记录" + (i + 2));
                });
            }
        });
    },
    _getMultiInputId: function (obj) {
        var tempId = [];
        $.each(obj.find(".select_rel").val().split(";"), function (i, n) {
            $.each(obj.find(".content input"), function (j, k) {
                if ($(this).val() == n && ($.inArray($(this).attr("attrindex"), tempId) == -1)) {
                    tempId.push($(this).attr("attrindex"));
                    return false;
                }
            });
        });
        return tempId;
    },
    _getFormParams: function (scope) {
        var obj = {};
        obj.bussId = scope.find(".check-sequence-span").next("input").val();
        obj.ctime = scope.find(".datepicker").val();
        obj.itemList = this._getMultiInputId(scope.find(".check-items-select"));
        obj.deptList = this._getMultiInputId(scope.find(".check-depts-select"));
        obj.contaList = scope.find(".multi_select_cabinetNo").find(".select_rel").val().split(";");
        /*obj.contaList=this._getMultiInputId(scope.find(".multi_select_cabinetNo"));*/
        obj.goodsList = this._getMultiInputId(scope.find(".check-goods-select"));
        if (scope.find(".checkDepts-input-container").css("display") == "block") {
            obj.otherDepts = scope.find(".check-depts-input").val();
        }
        if (scope.find(".checkItems-input-container").css("display") == "block") {
            obj.otherItems = scope.find(".check-items-input").val();
        }
        return obj;
    }
};